<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Links extends Model
{
    use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'eb_links';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'id',
        'long_url',
        'short_url',
        'keyword',
        'type',
        'project_id',
        'team_id',
        'created_at',
        'updated_at',
    ];

    protected $hidden = [
        'id',
        'team_id',
        // 'long_url',
    ];

    /**
     * 创建分享链接
     *
     * @Author hechengwei
     * @email chichiooo@sina.com
     * @DateTime 2022-04-14
     * @return void
     */
    public static function createLinks($long_url, $short_url, $keyword, $type, $project_id, $team_id, $platform = 'pc')
    {
        return self::create(compact('long_url', 'short_url', 'keyword', 'type', 'project_id', 'team_id', 'platform'));
    }

    public static function createSurveyLinks(array $surveyLinks)
    {
        return self::insert($surveyLinks);
    }

    public static function createCollectionLinks(array $collectionLinks)
    {
        return self::insert($collectionLinks);
    }
}
